// pages/discover/discover.js
const util = require('../../utils/util.js')
var app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    informations:[],
    location:'',
    tag:'',

    showScreenModal: false,
    showModal: false,
    address: ['文理学部', '工学部', '信息学部', '医学部'],
    tags: ['二手货', '跑腿', '组队'],
    tag_index:'',
    date: '2018-04-01',
    time: '12:01',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var i;
    for (i = 0; i < 10; i++) {
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    util.getAllInformation(this)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  infodetail_tap: function (e) {
    var index = e.currentTarget.dataset.idx
    app.globalData.info_detail = this.data.informations[index]
    wx.navigateTo({
      url: "infodetail/infodetail"
    })
  },

  addressPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    if (e.detail.value == 0){
      this.setData({
        location: '文理学部'
      })
    }
    else if (e.detail.value == 1){
      this.setData({
        location: '工学部'
      })
    }
    else if (e.detail.value == 2) {
      this.setData({
        location: '信息学部'
      })
    }else{
      this.setData({
        location: '医学部'
      })
    }
  },
  tagPickerChange: function (e) {
    this.setData({
      tag_index: e.detail.value
    })
    if (e.detail.value == 0) {
      this.setData({
        tag: '1'
      })
    }
    else if (e.detail.value == 1) {
      this.setData({
        tag: '2'
      })
    }
    else{
      this.setData({
        tag: '3'
      })
    }
  },

  hideModal: function () {
    this.setData({
      showIssueModal: false,
      showModal: false,
      showScreenModal: false
    });
  },
  
  onScreenCancel: function () {
    this.hideModal();
  },
  onScreenConfirm: function () {
    this.hideModal();
  },
  screen: function () {
    this.setData({
      showScreenModal: true,
      showModal: true
    })
  },

  release: function(){
    wx.navigateTo({
      url: "issue/issue"
    })
  }

})